var vm = new Vue({
    el: "section",
    data: {
        //header add
        search_value: "",
        showAction: false,
        userid: "",
        applicantList: []
    },
    methods: {
        // 搜索框
        onSearch() {
            // 检查输入内容
        },
        onFocus() {
            this.showAction = true;
        },
        onCancel() {
            this.showAction = false;
        },
        // 同意好友申请
        agree(userID){
            let loading2 = this.$toast.loading({
                message: '加载中...',
                forbidClick: true,
                duration: 10000,
                loadingType: 'circular'
            })
            let url = `https://fc-mp-e8e2bde5-0c0c-4622-87b5-66f8b08c3856.next.bspapp.com/getArticleList1.0`
            let method = `agreeApplican_4Hr1584bdS5v974g556`
            let data = {
                userid: this.userid,
                userID: userID
            }
            axios.post(`${url}/${method}`, data)
            .then(res=>{
                loading2.clear()
                if(res.data.code == 0){
                    this.$toast({
                        message: `已同意！`,
                        forbidClick: true
                    })
                    setTimeout(()=>{
                        this.applicantList = this.applicantList.filter((item, index)=> item.userid !== userID)
                    }, 2000)
                    
                }else{
                    this.$toast({
                        message:   `服务出错[${res.data.code}]`,
                        forbidClick: true
                    })
                }
            })
        },
    },
    mounted(){
        let loading1 = this.$toast.loading({
            message: `加载中...`,
            forbidClick: true,
            loadingType: 'circular',
            duration: 10000
        })
        let userInfo = localStorage.getItem('XGB-user')
        this.userid = JSON.parse(userInfo).id
        let url = `https://fc-mp-e8e2bde5-0c0c-4622-87b5-66f8b08c3856.next.bspapp.com/getArticleList1.0`
        let method = `getApplican_V891t1h8J114YK8AUL1k1`
        let data = {
            userid: this.userid
        }
        axios.post(`${url}/${method}`, data)
        .then(res=>{
            loading1.clear()
            if(res.data.code == 0){
                this.applicantList = res.data.data
            }else{
                this.$toast({
                    message: `服务出错[${res.data.code}]`,
                    forbidClick: true
                })
            }
        })
    }
})